package com.yesep.learn.design.behavioral.iterator;

import com.yesep.learn.design.common.pojo.*;

import java.util.*;

public class GoodsAggregateImpl implements IAggregate<Goods> {

    private final List<Goods> list = new ArrayList<>();

    @Override
    public void add(Goods obj) {
        this.list.add(obj);
    }

    @Override
    public void remove(Goods obj) {
        this.list.remove(obj);
    }

    @Override
    public IIterator<Goods> iterator() {
        return new GoodsIteratorImpl(list);
    }
}
